//
//  ProgramView.m
//  YIJU2.0-HD
//
//  Created by 张金国 on 16/5/9.
//  Copyright © 2016年 张金国. All rights reserved.
//

#import "ProgramView.h"
#import "UIColor+RandomColor.h"
#import "UIButton+ColorandText.h"
#import "TitleView.h"
#import "Masonry.h"
#import "Macro.h"
#import <MAMapKit/MAMapKit.h>
#import <AMapSearchKit/AMapSearchKit.h>


@interface ProgramView ()

@property (nonatomic ,strong)UIView  *view;

@property (nonatomic, strong)UIView    *sandBoxView;

@property (nonatomic, strong)MAMapView *mapView;


@end

@implementation ProgramView

#pragma mark - init
- (instancetype)init {
    if (self = [super init]) {
        [self setupConstraints];
    }
    return self;
}

#pragma mark - private
- (void)setupConstraints {
    [self.sandBoxView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.equalTo(self);
        make.width.equalTo(self.mas_width).multipliedBy(1/3.0f);
    }];
    [self.mapView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.bottom.equalTo(self);
        make.left.equalTo(self.sandBoxView.mas_right);
    }];
    
    [self setupConstraintsOfsandBoxView];
}

- (void)setupConstraintsOfsandBoxView {
    TitleView *titleView = [[TitleView alloc]initWithLineColor:[UIColor redColor] title:@"沙盘控制" titleFont:kLabelTextColor];
    [self.sandBoxView addSubview:titleView];
    [titleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.sandBoxView.mas_top).offset(20);
        make.left.equalTo(self.mas_left).offset(20);
        make.width.equalTo(self.sandBoxView.mas_width).offset(1/4.0f);
        make.height.equalTo(self.sandBoxView.mas_height).multipliedBy(0.05);
    }];
}

#pragma mark - getter
- (UIView *)sandBoxView {
    if (!_sandBoxView) {
        _sandBoxView = [[UIView alloc]init];
        _sandBoxView.backgroundColor = [UIColor randomColor];
        [self addSubview:_sandBoxView];
    }
    return _sandBoxView;
}

- (MAMapView *)mapView {
    if (!_mapView) {
        _mapView = [[MAMapView alloc]init];
        [self addSubview:_mapView];
    }
    return _mapView;
}


@end
